<template>
    <password-alert p-title='设置新密码' :p-submit='submitChange'></password-alert>
</template>
<script>
    import serAccess from '../../serves/api-access'
    export default{
        data(){
            return{

            }
        },
        methods:{
            handleOpen(data){
                this.$children&&this.$children[0].handleOpen(data);
            },
            async submitChange(data){
                const res =await serAccess.editPwd({
                    id:data.id,
                    password:data.password_new,
                });
                if(res.code==1){
                    this.$emit('on-ok');
                    this.$Notice.success({
                        title: res.message,
                        desc: '密码修改后需要重新登录',
                    });
                    this.$router.push('Login');
                    return true;
                }else{
                    this.$Message.error(res.message);
                    return false;
                }
            }
        },
        components:{
        }
    }
</script>